package com.heiyu.utils;

public class RateUtils {

    public static long repayAmount(long amount,int rate,int addRate,int dueDay,int collectDay,boolean isCollectRate){
        long total = 0l;
        if(isCollectRate)
            total = amount + Math.round(amount*(rate+addRate)*(dueDay+collectDay)/3600000);
        else
            total = amount+Math.round(amount*(rate+addRate)*dueDay/3600000);
        return total;
    }

    public static int format(String rate){
        if(rate.indexOf(".")<0){
            rate+=".00";
        }
        return Integer.valueOf(rate.replace(".",""));
    }

    public static String format(int rate){
        String r = rate+"";
        if(r.length()<3){
            r+="00000".substring(0,3-r.length());
        }
       return  r.substring(0,r.length()-2)+"."+r.substring(r.length()-2)+"%";
    }

}
